﻿
    using System;
    using System.Data;
    using System.Data.SqlClient;
    using System.Collections;
    using System.Collections.Generic;
    using FShop_DAL;

namespace FShop_BAL{

    ///<summary>
    ///The Class Provides methods for object operations. 
    ///</summary>
    ///<remarks>
    ///Changes to this file may cause incorrect behavior and will be lost if  the code is regenerated.
    ///Update the <see cref="User_BAL"/> class if you need to add or change some functionality
    ///</remarks>
    public class User_BAL  {

        #region Public Methods
		public static List<User> GetList_User()
		{
		   User_DAL obj = new User_DAL();
		   return obj.GetList_User();
		}

		public static DataTable Get_UserAsPaging(int pageIndex,int pageSize,string sSortColumn,string sFields,string sWhere,string sGroupBy)
		{
		   User_DAL obj = new User_DAL();
		   if (string.IsNullOrEmpty(sSortColumn)) sSortColumn = "";
		   if (string.IsNullOrEmpty(sWhere)) sWhere = "";
		   if (string.IsNullOrEmpty(sGroupBy)) sGroupBy = "";
		   if (string.IsNullOrEmpty(sFields)) sFields = "";
		   return obj.Get_UserAsPaging( pageIndex, pageSize, sSortColumn, sFields, sWhere, sGroupBy);
		}

		public static DataTable Get_UserAsTable(string whereSql,string orderBy)
		{
		   User_DAL obj = new User_DAL();
		   if (string.IsNullOrEmpty(orderBy)) orderBy = "";
		   if (string.IsNullOrEmpty(whereSql)) whereSql = "";
		   return obj.Get_UserAsTable(whereSql,orderBy);
		}

		public static User Get_User_ByID(System.Int32 User_ID)
		{
		   User_DAL obj = new User_DAL();
		   return obj.Get_User_ByID(User_ID);
		}
        public static User Get_User_ByName(String User_Name)
        {
            User_DAL obj = new User_DAL();
            return obj.Get_User_ByName(User_Name);
        }

		public static void Delete_User(User temp)
		{
		   User_DAL obj = new User_DAL();
		   obj.Delete_User( temp);
		}

		public static void Delete_User_Where(string whereSql)
		{
		   User_DAL obj = new User_DAL();
		   if (string.IsNullOrEmpty(whereSql)) whereSql = "";
		   obj.Delete_User_Where( whereSql );
		}

		public static void Insert_User(User temp)
		{
		   User_DAL obj = new User_DAL();
		   obj.Insert_User(temp);
		}

		public static void Update_User(User temp)
		{
		   User_DAL obj = new User_DAL();
		   obj.Update_User(temp);
		}

#endregion

        public static bool IsExitUser(string userName, string password, ref string mem_ID)
        {
            DataTable tbl = User_BAL.Get_UserAsTable("User_Name='" + userName.Trim() + "' AND User_Password='" + password.Trim() + "'", "");

            if (tbl == null || tbl.Rows.Count == 0)
                return false;
            else
            {
                mem_ID = (tbl.Rows[0]["User_ID"].ToString());
                return true;
            }
        }
    }
}
